<!--extend SysNaples/Index/base_bootstrap-->
<!--已使用naples bootstrap模板-->

<block_title>收藏夹</block_title>

<block_head>
    <!--head-->
    <style>
        body{
            background-color: rgb(238,238,238);
            font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu
        }
        .item{
            margin: 5px;
        }
        .btn-del{display: none}
        .grp-visit{width: 100%}
        .grp-visit:hover .btn-del{display: inline-block}
    </style>
    {{inc SysNaples/Index/particle}}
</block_head>

<block_body>
    <div class="container">
        <div class="row">
            <div class="jumbotron" style="background-color:transparent">
                <h2 style="color: #0B5979">Naples 快速收藏夹</h2>

                <div class="row">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <a href="{{url SysNaples/Admin}}">后台管理</a>
                        </li>
                        <li>
                            <a href="https://git.coding.net/yuri2/naples_php.git" target="_blank">项目地址</a>
                        </li>
                        <li class="active">
                            <a href="{{url Home/Demos}}">预览特性</a>
                        </li>
                        <li class="active">
                            <a href="#">帮助手册</a>
                        </li>
                        <li class="active">
                            <a href="http://yuri2.cn/blog" target="_blank">Yuri2's Blog</a>
                        </li>
                    </ul>
                </div>
                <div class="row">
                    <form action="{{url addAFav based}}" style="margin:10px 5px;margin-bottom: 60px" method="post" class="form-inline col-md-12" role="form">
                        <div class="form-group">
                            <label class="sr-only" for="ipt_url">label</label>
                            <input style="min-width:500px;" type="url" class="form-control" name="href" id="ipt_url" placeholder="添加网址 ...">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="ipt_title">label</label>
                            <input type="text" class="form-control" name="name" id="ipt_title" placeholder="添加标题 ...">
                        </div>
                        <button type="submit" class="btn btn-primary">添加</button>
                    </form>

                    {{each $favs}}
                        <div class="col-md-4 col-sm-6">
                            <div class="item">
                                <div class="btn-toolbar" role="toolbar">
                                    <div class="btn-group grp-visit">
                                        <a type="button" title="{{:v.name}}" href="{{:v.href}}" style="width:70%;overflow: hidden" target="_blank" class="btn btn-default">
                                            {{:v.name}}
                                        </a>
                                        <a href="{{url delFav ['id'=>$k] based}}" title="删除" type="button" class="btn btn-default btn-del"><span class="glyphicon glyphicon-trash"></span></a>
                                    </div>
                                </div>

                            </div>

                        </div>
                    {{/}}
                </div>
            </div>
        </div>
    </div>
    <script>
        $('#ipt_url').change(function () {
           var val=$(this).val();
            $.ajax({
                type: "POST",
                url: "{{url getTitle based}}",
                data: {
                    url:val
                },
                dataType: "json",
                async:true,

                success: function(data){
                    if (data.errno!=0){
                        alert('很抱歉，操作发生错误。错误码:'+data.errno+'错误信息:'+data.msg)
                    }
                    $('#ipt_title').val(data.data);
                },
                error:function () {
                    //alert('错误，远程服务器没有响应.')
                }
            });
        });
    </script>
</block_body>